<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jquery-3.3.1.js"></script>
</head>
<body>
    <input type="text">
    <ul class="nav"></ul>
    <script>
        $('input').on('input',function (){
            let val = this.value ; 
            if( val.trim().length ){
                $.ajax({
                    url:'https://suggestion.baidu.com/su',
                    dataType:'jsonp',
                    jsonp:'cb',
                    data:{
                        wd:val,
                    },
                    success(res){
                        let str = '' ;
                        res.s.forEach(item=>{
                            str += `<li>${item}<li>`;
                        });
                        $(".nav").html(str);
                    }
                });
            } else {
                $(".nav").html('');
            }
           
        })
    </script>
</body>
</html>